<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 注意：项目正式环境请勿引用该地址 -->
    <link href="../layui/css/layui.css" rel="stylesheet">
    <title>java后台代码生成</title>
</head>
<body>
<form class="layui-form" lay-filter="fm" action="generator/generate" method="post">
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>基本配置</legend>
        <div class="layui-form-item">
            <label class="layui-form-label">表名</label>
            <div class="layui-input-block">
                <input type="text" name="tableName" lay-verify="title" autocomplete="off" placeholder="表名: dfl_user"
                       class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">实体名</label>
            <div class="layui-input-block">
                <input type="text" name="entityName" lay-verify="title" autocomplete="off"
                       placeholder="实体名: DflUser(PO)" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">模块名称</label>
            <div class="layui-input-block">
                <input type="text" name="modelName" lay-verify="title" autocomplete="off"
                       placeholder="模块名称，代码安放的目录: dflsystem" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">全包名</label>
            <div class="layui-input-block">
                <input type="text" name="pkg" lay-verify="pkg" autocomplete="off"
                       placeholder="全包名: org.ccs.opendfl.mysql.dflsystem" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">前端UI类型</label>
            <div class="layui-input-block">
                <input type="checkbox" name="uiTypes" value="easyui" lay-skin="primary" title="easyui" checked="">
                <input type="checkbox" name="uiTypes" value="jqgrid" lay-skin="primary" title="jqgrid">
                <input type="checkbox" name="uiTypes" value="layui" lay-skin="primary" title="layui">
            </div>
        </div>
    </fieldset>
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>字段处理</legend>
        <div class="layui-form-item">
            <label class="layui-form-label">隐藏属性</label>
            <div class="layui-input-block">
                <input type="text" name="hideGridColumns" lay-verify="title" autocomplete="off"
                       placeholder="隐藏属性: ifDel" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">下拉选项</label>
            <div class="layui-input-block">
                <input type="text" name="dictColumns" lay-verify="title" autocomplete="off"
                       placeholder="下拉选项: status:dict_status" class="layui-input">
            </div>
        </div>
    </fieldset>
    <fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
        <legend>注释信息</legend>
        <div class="layui-form-item">
            <label class="layui-form-label">作者</label>
            <div class="layui-input-block">
                <input type="text" name="author" lay-verify="title" autocomplete="off"
                       placeholder="作者: Generator" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">公司</label>
            <div class="layui-input-block">
                <input type="text" name="company" lay-verify="title" autocomplete="off"
                       placeholder="公司: opendfl" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">copyright</label>
            <div class="layui-input-block">
                <input type="text" name="copyright" lay-verify="title" autocomplete="off"
                       placeholder="copyright: 2022 opendfl Inc. All rights reserved." class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label">是否支持swagger</label>
            <div class="layui-input-block">
                <input type="checkbox" checked="" name="swagger" lay-skin="switch" lay-filter="swagger"
                       lay-text="ON|OFF">
            </div>
        </div>
    </fieldset>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">代码生成</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
</form>
<script src="../layui/layui.js"></script>
<script>
    layui.use(['form', 'layer'], function () {
        var form = layui.form;
        var $ = layui.$;
        var layer = layui.layer;

        //加载默认配置
        $.ajax({
            type: "POST",
            url: "/generator/defaultConfig",
            contentType: "application/json",
            success: function (data) {
                console.log(data)
                //form.val('fm', JSON.parse(JSON.stringify(data)));
                form.val('fm', data);
                form.render();
            },
            error: function (data) {
                layer.msg("数据加载失败", data);
            }
        });

        //自定义验证规则
        form.verify({
            title: function (value) {
                if (value.length < 4) {
                    return '至少得4个字符啊';
                }
            }
        });

        //指定开关事件
        form.on('switch(swagger)', function (data) {
            layer.msg('开关swagger：' + (this.checked ? '开' : '关'), {
                offset: '6px'
            });
            if (!this.checked) {
                layer.tips('温馨提示：关闭后将不生成swagger文档代码', data.othis)
            }
        });
    });
</script>
</body>
</html>